package edu.towson.cosc.cosc455.mlam4.compiler;

import java.util.ArrayList;

public class MySemanticAnalyzer {
	
	public static ArrayList<String> htmlTree = new ArrayList<String>();
    static String token;

	
	
	public void convert(){
		for(int i =0;i<MyCompiler.parseTree.size();i++){
			token = MyCompiler.parseTree.get(i);
			if(token.equalsIgnoreCase(LexicalTokens.DOC_BEGIN))
				htmlTree.add("<html>");
			else if(token.equalsIgnoreCase(LexicalTokens.DOC_END))
				htmlTree.add("</html>");            
			else if(token.equalsIgnoreCase(LexicalTokens.COMMENT_BEGIN))
				htmlTree.add("<!--");
			else if(token.equalsIgnoreCase(LexicalTokens.COMMENT_END))
				htmlTree.add("-->");
			else if(token.equalsIgnoreCase(LexicalTokens.HEAD_BEGIN))
				htmlTree.add("<head>");
			else if(token.equalsIgnoreCase(LexicalTokens.HEAD_END))
				htmlTree.add("</head>"); 
			else if(token.equalsIgnoreCase(LexicalTokens.TITLE_BEGIN))
				htmlTree.add("<title>");         
			else if(token.equalsIgnoreCase(LexicalTokens.TITLE_END))
				htmlTree.add("</title>");  
			else if(token.equalsIgnoreCase(LexicalTokens.PARAGRAPH_BEGIN))
				htmlTree.add("<p>");     
			else if(token.equalsIgnoreCase(LexicalTokens.PARAGRAPH_BEGIN))
				htmlTree.add("</p>");  
			else if(token.equalsIgnoreCase(LexicalTokens.BOLD_BEGIN))
				htmlTree.add("<b>");         
			else if(token.equalsIgnoreCase(LexicalTokens.BOLD_END))
				htmlTree.add("</b>");   
			else if(token.equalsIgnoreCase(LexicalTokens.ITALICS_BEGIN))
				htmlTree.add("<i>");        
			else if(token.equalsIgnoreCase(LexicalTokens.ITALICS_END))
				htmlTree.add("</i>");
			else if(token.equalsIgnoreCase(LexicalTokens.LIST_BEGIN))
				htmlTree.add("<ul>");          
			else if(token.equalsIgnoreCase(LexicalTokens.LIST_END))
				htmlTree.add("</ul>"); 			
			else if(token.equalsIgnoreCase(LexicalTokens.ITEM_BEGIN))
				htmlTree.add("<li>");          
			else if(token.equalsIgnoreCase(LexicalTokens.ITEM_END))
				htmlTree.add("</li>"); 
            else if(token.equalsIgnoreCase(LexicalTokens.NEWLINE))
            	htmlTree.add("<br>"); 
			else if(token.equalsIgnoreCase(LexicalTokens.SOUNDS_BEGIN))
				htmlTree.add("<audio controls><source src=");
			else if(token.equalsIgnoreCase(LexicalTokens.SOUNDS_END))
				htmlTree.add("></audio>");     
			else if(token.equalsIgnoreCase(LexicalTokens.VIDEO_BEGIN))
				htmlTree.add("<iframe src=");        
			else if(token.equalsIgnoreCase(LexicalTokens.VIDEO_BEGIN))
				htmlTree.add("/>");
			else if(token.equalsIgnoreCase(LexicalTokens.VARIABLE_DEFINE_BEGIN))
				htmlTree.add(token);  
			else if(token.equalsIgnoreCase(LexicalTokens.VARIABLE_DEFINE_MIDDLE))
			    htmlTree.add(token);    
			else if(token.equalsIgnoreCase(LexicalTokens.VARIABLE_DEFINE_END))
				htmlTree.add(token);
			else
				htmlTree.add(token);
		}
	}
		public static void printTrees(){
			
			for(int j =0; j<htmlTree.size();j++){
				token = MyCompiler.parseTree.get(j);
				System.out.print(token);
			}
		}
	}
